package ebj.common.reflection;

import java.lang.reflect.Method;

import ebj.common.proxy.Person;
import ebj.common.utils.Utils;


/**
 * 反射实例7：获得其他类中的全部函数，及其访问修饰符
 * @author zhouxiangyong
 * @version $Id$
 */
public class ReflectClient7 {
	public static void main(String[] args) {
		String clazzName = Utils.getProperty("Person");
		Class<?> clazz = null;
		Person person = null;
		try {
			clazz = Class.forName(clazzName);
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.out.println("**************所有用户自声明的方法(包含私有的、受保护的 以及 友好的)**************");
		Method[] allMethods = clazz.getDeclaredMethods();
		for (int i = 0; i < allMethods.length; i++) {
			System.out.println(allMethods[i]);
		}
		System.out.println();
		System.out.println("**************所有方法(只公共的)(包含自声明的和从父类继承而来的公共方法)**************");
		Method[] methods = clazz.getMethods();
		for (Method method : methods) {
			System.out.println(method);
		}
		
		try {
			person = (Person) clazz.newInstance();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
